package cn.com.zal.cgweb.common.utils;

import java.util.List;

import cn.com.zal.cgweb.pojo.TcAddress;
import cn.com.zal.cgweb.pojo.TcAddressDAO;

public class TcAddressUtil {
	public static TcAddressDAO addressDAO = new TcAddressDAO();

	public static List<TcAddress> getUserAddresses(Long userId) {
		return addressDAO.findByProperty(TcAddressDAO.USER_ID,
				userId);
	}
	
//	public static void addUserAddress(TcAddress address){
////		try{
//			addressDAO.save(address);
////		}catch(){
////			
////		}
//	}
	public static TcAddress getUserDefaultAddresses(Long userId) {
		List<TcAddress> address = addressDAO.findByProperty(TcAddressDAO.USER_ID,
				userId);
		if(address == null){
			return null;
		}
		for(int i=0; i<address.size(); i++){
			if(address.get(i).getIsDefalut()){
				return address.get(i);
			}
		}
		return null;
	}
}


